package com.richpay.basejava.base10;

public class Company implements Cloneable {
    private String name;
    private int age;
    private Employee employee;

    public Company() {
        super();
    }

    public Company(String name, int age, Employee employee) {
        this.name = name;
        this.age = age;
        this.employee = employee;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    @Override
    public String toString() {
        return "Company{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", employee=" + employee +
                '}';
    }

    /**
     * 深度克隆
     * @return
     * @throws CloneNotSupportedException
     */
    @Override
    protected Object clone() throws CloneNotSupportedException {
        Company company = (Company) super.clone();
        Employee employee = (Employee) this.employee.clone();
        company.setEmployee(employee);
        return company;
    }
}
